#include "EventBase.h"

#include <folly/fibers/FiberManagerMap.h>
#include <iostream>

namespace nexus {

EventBase::EventBase() : fiberManager_(folly::fibers::getFiberManager(evb_)) {}

EventBase::~EventBase() {
  std::cout << "DONE evb" << std::endl;
  stop();
}

void
EventBase::run() {
  evb_.loopForever();
}
void
EventBase::stop() {
  for (auto& future : fiberTaskFutures_) {
    future.wait();
  }
  evb_.terminateLoopSoon();
}

} // namespace nexus